package com.zhibang.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("com.zhibang.mapper")
public class PlusConfig {

    @Bean
    public MybatisPlusInterceptor mpi(){
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        // 分页插件
        PaginationInnerInterceptor pii = new PaginationInnerInterceptor();
        pii.setDbType(DbType.MYSQL);
        pii.setOverflow(true); // 页码溢出处理
        mpi.addInnerInterceptor(pii);
        return mpi;
    }
}
